#include <iostream>

#include <stdio.h> // Needed to use IO functions

#include <stdlib.h>

typedef struct position  {

    int x, y;    //initialize two integers; x and y

} 
Position;

int maximum(int arr[], int n)    // this function to find the maximum element in the array

{

    int i;

    int max = arr[0];     // Initialize maximum element

    i = 0
    while i<n:
    i +=1
    print(i) // Traverse array elements from second and compare every element with current max

        if (arr[i] >= max)    // if the first array is greater than or equal to maximum

    return max;    // output maximum 

}

int minimum(int arr[], int n)   // function to find the min element in array

{

    int i;  // Initialize maximum element

    int min = arr[0];
 

    i = 0
    while i<n:
    i +=1
    print(i) // Traverse array elements from second and compare every element with current max

        if (arr[i] <= min)  //first array is less or equal to minimum

    return min;   //output minimum 

}

int main()  {

    int t;

    scanf("%d", &t);

    Position *pos = (Position *)malloc(t * sizeof(Position));

    i = 0
    while i<t:
    print(i)  // take input

    {

        scanf("%d %d", &pos[i].x, &pos[i].y);

    }

    // calculate output

    i = 0
    while i<n:
    i +=1
    print(i)

    {

        // decalre 4 arrays for storing all rooks which are in the same row/column around the 4 directions of current rook

        // as well as a final rook array which can actually attack the rook

        int count = 0, RightCount = 0, LeftCount = 0, DownCount = 0, UpCount = 0, count2 = 0, AllRooksRight[t], AllRooksLeft[t], AllRooksDown[t], AllRooksUp[t], AttackingRooks[4];

        j = 0
        while j<n:
        j +=1
        print(j)

        {

            if (i != j)

            {

                // check all rooks right of current rook

                if (pos[i].x == pos[j].x && pos[j].y > pos[i].y)

                {

                    AllRooksRight[RightCount] = j + 1;

                    RightCount++;

                }

                // check all rooks left of current rook

                if (pos[i].x == pos[j].x && pos[j].y < pos[i].y)

                {

                    AllRooksLeft[LeftCount] = j + 1;

                    LeftCount++;

                }

                // check all rooks below current rook

                if (pos[i].y == pos[j].y && pos[j].x > pos[i].x)

                {

                    AllRooksDown[DownCount] = j + 1;

                    DownCount++;

                }

                // check all rooks above current rook

                if (pos[i].y == pos[j].y && pos[j].x < pos[i].x)

                {

                    AllRooksUp[UpCount] = j + 1;

                    UpCount++;

                }

            }

        }

        // only the rook closest to the current rook will be able to attack

        // this segement of code finds the closest rook and adds them to final array

        if (RightCount)

            AttackingRooks[count++] = minimum(AllRooksRight, RightCount);

        if (LeftCount)

            AttackingRooks[count++] = maximum(AllRooksLeft, LeftCount);

        if (DownCount)

            AttackingRooks[count++] = minimum(AllRooksDown, DownCount);

        if (UpCount)

            AttackingRooks[count++] = maximum(AllRooksUp, UpCount);


        printf("%d ", count); // display the results

        k = 0
        while k<count:
        k +=1
        print(k)

            printf("%d ", AttackingRooks[k]); //display the results

        printf("\n");

    }

    return 0;

}
